<template>
  <div class="child">
    <h2>我是child2组件</h2>
    <h3>哥哥给的手机:{{ iphone }}</h3>
  </div>
</template>

<script>
export default {
  name: 'Child',
  data() {
    return {
      iphone: '',
    }
  },
  methods: {
    isSH(val) {
      this.iphone = val
    },
  },
  mounted() {
    this.$bus.$on('getPhone', this.isSH)
  },

  // 组件销毁前,清除                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               事                                                                                                                                                                            件
  beforeDestroy() {
    this.$bus.$off('getPhone')
  },
}
</script>

<style scoped>
.child {
  padding: 20px;
  background-color: rgb(69, 165, 225);
  box-shadow: 0 0 10px;
}
</style>